package org.thread.test05.demo04;

/**
 * @author ZJL
 * @date 2025-03-12
 */
public class MainTest {
    public static void main(String[] args) {
//        七、编写 Java 程序，模拟多个用户使用同一台打印机打印数据。
//        需要告诉打印机使用者和打印的内容。
//        如：张三，李四使用打印机打印某字符，输出的结果为：
//
//        张三：AAAA
//        李四：BBBB
//
//        同步块 + 同步方法 + 测试各种类型的锁对象
//        Printer user = new Printer();
//        MyRunnable myRunnable1 = new MyRunnable(user,"AAA");
//        MyRunnable myRunnable2 = new MyRunnable(user,"BBB");
//        Thread t1 = new Thread(myRunnable1,"张三");
//        Thread t2 = new Thread(myRunnable2,"李四");
//        t1.start();
//        t2.start();

        Printer printer = new Printer();
        MyThread mt01  =new MyThread(printer,"张三","AAA");
        MyThread mt02  =new MyThread(printer,"李四","BBB");
        MyThread mt03  =new MyThread(printer,"王五","CCC");
        MyThread mt04  =new MyThread(printer,"赵六","DDD");
        mt01.start();
        mt02.start();
        mt03.start();
        mt04.start();

    }
}
